import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'

Vue.config.productionTip = false;
Vue.prototype.$axios = axios;

router.beforeEach((to,from,next) => {
	var isAuth = to.matched.some((ele) => {
		return ele.meta.requestAuth
	})
	if(isAuth){
		//即将跳去我的页面，验证用户是否登录
		var token = localStorage.getItem('token');
		if(!token){
			//拦截，跳去登录页
			next({
				path: '/login',
				query:{
					redirectUrl:to.fullPath
				}
			})
		}else{
			next()
		}
	}else{
		next();
	}
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
